{extend name="common/base" /}
{block name="style"}
<style type="text/css">
    * {
        touch-action: none; 
    }
    a{
        color: #000;
    }
</style>
{/block}
{block name="body"}
<div class="soye-hui">
    <div class="ddlb-mains">
        <ul class="ddlb-nav">
            <li <?php if($s==1):?>  class="active" <?php endif;?>> <a href="{:url('Task/index',array('s'=>1))}"><span>待上刊</span></a></li>
            <li <?php if($s==10):?>  class="active" <?php endif;?>><a href="{:url('Task/index',array('s'=>10))}"><span>进行中</span></a></li>
            <li <?php if($s==20):?>  class="active" <?php endif;?>><a href="{:url('Task/index',array('s'=>20))}"><span>已完成</span></a></li>
            <li <?php if($s==90):?>  class="active" <?php endif;?>><a href="{:url('Task/index',array('s'=>90))}"><span>已失效</span></a></li>
        </ul>
        <!-- 待上刊 -->
        <div id="pullrefresh" class="mui-content mui-scroll-wrapper " style='top:0.4rem;' >
            <div class="mui-scroll">
                <ul class="ddlb-list mui-table-view mui-table-view-chevron js-item" style="background:#efeff4;">
                </ul>
            </div>
        </div>                      
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    mui.init({
        pullRefresh: {
            container: '#pullrefresh',
            up: {
                height: 50, //可选.默认50.触发上拉加载拖动距离
                auto: true, //可选,默认false.自动上拉加载一次
                contentrefresh: '正在加载...',
                contentnomore: '没有更多数据了', //可选，请求完毕若没有更多数据时显示的提醒内容；
                callback: pullupRefresh
            }
        }

    });
    
    mui('body').on('tap', 'a', function () {
        window.top.location.href = this.href;
    });

    var p = 0;
    var s = '<?php echo $s;?>';
    /**
     * 上拉加载具体业务实现
     */
    function pullupRefresh() {
        setTimeout(function () {
            $.post("{:url('Task/item')}", {p: p, s: s}, function (res) {
                if (res) {
                    $(".js-item").append(res);
                    p++;
                    mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
                } else {
                    mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
                }
            }, 'json');

        }, 1500);
    }
    $(".ddlb-nav li").bind('click', function () {
        $(this).addClass("active").siblings().removeClass("active");
        $('.ddlb-list').eq($(this).index()).show().siblings(".ddlb-list").hide();
    });
</script>
{/block}